use [property]
go

/****** object:  table [dbo].[user]    script date: 02/07/2011 17:21:41 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[user](
	[user_id] [uniqueidentifier] not null,
	[fname] [varchar](50) not null,
	[lname] [varchar](50) not null,
	[mobile] [varchar](10) not null,
 constraint [pk_user] primary key clustered 
(
	[user_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go


use [property]
go

/****** object:  table [dbo].[roles]    script date: 02/07/2011 17:22:21 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[roles](
	[role_id] [uniqueidentifier] not null,
	[role_name] [varchar](50) not null,
	[description] [varchar](100) not null,
 constraint [pk_roles] primary key clustered 
(
	[role_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go


use [property]
go

/****** object:  table [dbo].[user_in_role]    script date: 02/07/2011 17:22:41 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[user_in_role](
	[user_id] [uniqueidentifier] not null,
	[role_id] [uniqueidentifier] not null,
 constraint [pk_user_in_role] primary key clustered 
(
	[user_id] asc,
	[role_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go

alter table [dbo].[user_in_role]  with check add  constraint [fk_role_id_user_in_role] foreign key([role_id])
references [dbo].[roles] ([role_id])
go

alter table [dbo].[user_in_role] check constraint [fk_role_id_user_in_role]
go

alter table [dbo].[user_in_role]  with check add  constraint [fk_user_id_role_user_in_role] foreign key([user_id])
references [dbo].[user] ([user_id])
go

alter table [dbo].[user_in_role] check constraint [fk_user_id_role_user_in_role]
go


use [property]
go

/****** object:  table [dbo].[user_membership]    script date: 02/07/2011 17:22:53 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[user_membership](
	[user_id] [uniqueidentifier] not null,
	[password] [varchar](40) not null,
	[email_id] [varchar](100) not null,
	[isapproved] [tinyint] null,
	[createdate] [date] not null,
	[approvedate] [date] null,
 constraint [pk_email_id_user_membership] primary key clustered 
(
	[email_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go

alter table [dbo].[user_membership]  with check add  constraint [fk_user_id_user_membership] foreign key([user_id])
references [dbo].[user] ([user_id])
go

alter table [dbo].[user_membership] check constraint [fk_user_id_user_membership]
go


///
state
///
use [property]
go

/****** object:  table [dbo].[city_in_state]    script date: 02/07/2011 17:23:24 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[city_in_state](
	[state_id] [uniqueidentifier] not null,
	[city_id] [uniqueidentifier] not null,
	[city_name] [varchar](30) not null,
 constraint [pk_city_in_state] primary key clustered 
(
	[state_id] asc,
	[city_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go


use [property]
go

/****** object:  table [dbo].[location]    script date: 02/07/2011 17:23:43 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[location](
	[location_id] [uniqueidentifier] not null,
	[location_name] [varchar](100) not null,
	[landmark] [varchar](100) not null,
	[isapproved] [tinyint] null,
 constraint [pk_location] primary key clustered 
(
	[location_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go


use [property]
go

/****** object:  table [dbo].[location_in_city]    script date: 02/07/2011 17:23:55 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[location_in_city](
	[lic_id] [uniqueidentifier] not null,
	[state_id] [uniqueidentifier] not null,
	[city_id] [uniqueidentifier] not null,
	[location_id] [uniqueidentifier] not null,
 constraint [pk_location_in_city] primary key clustered 
(
	[lic_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go

alter table [dbo].[location_in_city]  with check add  constraint [fk_location_id_location_in_city] foreign key([location_id])
references [dbo].[location] ([location_id])
go

alter table [dbo].[location_in_city] check constraint [fk_location_id_location_in_city]
go

alter table [dbo].[location_in_city]  with check add  constraint [fk_state_city_id_location_in_city] foreign key([state_id], [city_id])
references [dbo].[city_in_state] ([state_id], [city_id])
go

alter table [dbo].[location_in_city] check constraint [fk_state_city_id_location_in_city]
go


use [property]
go

/****** object:  table [dbo].[advertisement]    script date: 02/07/2011 17:24:13 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[advertisement](
	[add_id] [uniqueidentifier] not null,
	[title] [varchar](100) not null,
	[lic_id] [uniqueidentifier] not null,
	[isforrent] [tinyint] null,
	[isforsell] [tinyint] null,
	[description] [varchar](400) null,
	[cost_for_rent] [decimal](18, 0) not null,
	[cost_for_sell] [decimal](18, 0) not null,
	[createdate] [date] not null,
 constraint [pk_advertisement] primary key clustered 
(
	[add_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go


use [property]
go

/****** object:  table [dbo].[user_advertisement]    script date: 02/07/2011 17:24:24 ******/
set ansi_nulls on
go

set quoted_identifier on
go

create table [dbo].[user_advertisement](
	[user_id] [uniqueidentifier] not null,
	[add_id] [uniqueidentifier] not null,
	[isapproved] [tinyint] null,
	[approvedate] [date] null,
 constraint [pk_user_advertisement] primary key clustered 
(
	[user_id] asc,
	[add_id] asc
)with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary]
) on [primary]

go

alter table [dbo].[user_advertisement]  with check add  constraint [fk_add_id_user_advertisement] foreign key([add_id])
references [dbo].[advertisement] ([add_id])
go

alter table [dbo].[user_advertisement] check constraint [fk_add_id_user_advertisement]
go

alter table [dbo].[user_advertisement]  with check add  constraint [fk_user_id_user_advertisement] foreign key([user_id])
references [dbo].[user] ([user_id])
go

alter table [dbo].[user_advertisement] check constraint [fk_user_id_user_advertisement]
go


